#ifndef _MPU6050_H_
#define _MPU6050_H_

#include <stdint.h>

typedef struct mpu6050 {
	struct {
		struct {
			/**
			 * MPU6050 PIN9 AD0 用于配置 I2C 设备地址
			 * AD0 --- GND: 7bit address 0x68
			 * AD0 --- VCC: 7bit address 0x69
			 */
			int device_address;
		} fix;
		struct {
			int res;
		} var;
	} cfg;
	struct {
		/**
		 * memory_address 正常情况下是直接使用 uint8_t 类型的
		 * 这里使用指针是是为了增加一个 NULL 状态，表明本次通信不需要发送寄存器地址
		 */
		int (*i2c_read)(uint8_t device_address, uint8_t* memory_address, uint8_t* buffer, uint32_t length);
		int (*i2c_write)(uint8_t device_address, uint8_t* memory_address, uint8_t* buffer, uint32_t length);
		void (*msleep)(int ms);
		unsigned long (*get_ms)();
	} ops;
} mpu6050_t;

int mpu6050_init(mpu6050_t *sensor);
int mpu6050_read(float* pitch, float* roll, float* yaw);

#endif
